package georah.carto.geometries
{

	/**
	 * 
	 * @author yuanm
	 */
	public class OGCLineString extends OGCCurve
	{
		public static const TYPE:String="LineString";

		private var _OGCPoints:Array /* of GOGCPoint */ =[];

		public final function OGCPointN(n:int):OGCPoint
		{
			return _OGCPoints[n];
		}

		override public function get asText():String
		{
			var header:String="SRID=" + SRID + ";" + OGCLineString.TYPE + "(";
			var wkts:Array=[];
			for each (var pt:OGCPoint in _OGCPoints)
			{
				wkts.push(pt.x + " " + pt.y);
			}
			var tail:String=")";

			return header + wkts.join(",") + tail;
		}

		override public function get endOGCPoint():OGCPoint
		{
			if (numOGCPoints < 1)
			{
				return null;
			}
			else
			{
				return _OGCPoints[numOGCPoints - 1];
			}
		}

		override public function get envelope():Extent
		{
			return null; //TODO
		}

		override public function get isClosed():Boolean
		{
			return false; //TODO
		}

		override public function get isRing():Boolean
		{
			return false; //TODO
		}

		public final function get numOGCPoints():int
		{
			return _OGCPoints.length;
		}

		override public function get startOGCPoint():OGCPoint
		{
			if (numOGCPoints < 1)
			{
				return null;
			}
			else
			{
				return _OGCPoints[0];
			}
		}

	}
}
